## Euler's totient function 
from PyM import *


f = phi_euler

show(f(105))

show(f(123456789))

show(f(1234567890123456789))

#show(f(),\nl)

# Small values of f(n)/n

def P(N):
    if N<2: return []
    return [2] + [2*k+1 for k in range(1,1+(N-1)//2) if is_prime(2*k+1)]

# The following funtion coincides with f(P_N)/P_N, where P_N = product(P(N))
def m(N): return product([(p-1)/p for p in P(N)])

show(m(10))

show(m(100))

show(m(1000))

show(m(10000))

# Example that the sum of f(d), for d divisor or n, is n.

n = 9*5*7

D = divisors(n)

S = sum([f(d) for d in D])

show('n = ',n, 'S = ', S)
